package java_test.collection;

import java.util.*;

public class CollectionCompare {
    public static void main(String[] args) {
        String[] coins = {"Penny", "nickel", "dime", "Quarter", "dollar"};
        Set<String> set = new TreeSet<String>();
        for (int i = 0; i < coins.length; i++) {
            set.add(coins[i]);
        }

        System.out.println(Collections.min(set));
        System.out.println(Collections.min(set, String.CASE_INSENSITIVE_ORDER));
        for (int i = 0; i <= 10; i++) {
            System.out.print("-");
        }
        System.out.println("");
        System.out.println(Collections.max(set));
        System.out.println(Collections.max(set, String.CASE_INSENSITIVE_ORDER));

        HashMap<String, String> hMap = new HashMap<String, String>();
        hMap.put("1", "1st");
        hMap.put("2", "2nd");
        hMap.put("3", "3rd");

        Collection cl = hMap.values();
        Iterator itr = cl.iterator();
//        Java Iterator（迭代器）不是一个集合，它是一种用于访问集合的方法，
//        可用于迭代 ArrayList 和 HashSet 等集合。
        while (itr.hasNext()) {
            System.out.println(itr.next());
        }

    }
}
